

const { Schema, model } = require('mongoose')


// Schema  声明表结构   对表的数据进行约束  (表字段的 类型校验)

const AppUserSchema = new Schema({
    id: String,
    username: String,
    phone: String,
    password: String,
    avatar: String,  // 头像
    nickname: String,
    email: String,
    age: Number,
    sex: Number,
    time: Date,
    role: Number,
})


exports.AppUserModel = model('appusers', AppUserSchema)


// const GoodSchema = new Schema({
//     "id": String ,
//     "zhu10id": String,
//     "name": String,
//     "price": Number,
//     "discount": Number,
//     "img": String,
//     "type":Object 
// })


// exports.AppGoodModel = model("goods",GoodSchema)




const AppCartSchema = new Schema({
    count: Number,
    good: Object,
    goodId: String,
    phone: String,
    userInfo: Object,
    check: Boolean,
})


exports.AppCartModel = model('appcarts', AppCartSchema)



const AppLikeSchema = new Schema({
    good: Object,
    goodId: String,
    phone: String,
    hasLike: Number, // 1 已经操作 0 没有
    hasCollect: Number // 1 已经操作 0 没有
})
exports.AppLikeModel = model('applikes', AppLikeSchema)



const AppCollectSchema = new Schema({
    good: Object,
    goodId: String,
    phone: String,
})
exports.AppCollectModel = model('appcollects', AppCollectSchema)


// 评论
const AppCommentSchema = new Schema({
    good: Object,
    goodId: String,
    phone: String,
    userInfo: Object,
    title: String,  // 评论的内容
    time: Date
})
exports.AppCommentModel = model('appcomments', AppCommentSchema)